<template>
  <view class="Water">
    <mineNavbar :styleData="styleData" @scrolltolower="scrollBottom" />

    <scroll-view class="scroll" scroll-y>
      <view class="item" v-for="day in items">
        <view class="left">
          <view class="day"> {{ day.description }} </view>
          <view class="time"> {{ day.createTime }} </view>
        </view>
        <view :class="day.type === '2' ? 'payOut' : 'right'">
          <text>{{ day.type === '1' ? '+' : '-' }}</text>
          <text>{{ day.quantity }}</text>
        </view>
      </view>
    </scroll-view>
  </view>
</template>

<script>
import { getIntegralLogAPI } from "@/api/subPage/mine";
export default {
  components: {},
  data() {
    return {
      styleData: {
        show: true,
        tabbarText: "积分流水",
      },

      items: [
        {
          description: "每日签到",
          createTime: "2024.03.09 12:39:16",
          quantity: "30",
          type: ''
        },
      ],

      form: {
        pageNum: 1,
        pageSize: 10,
      },
    };
  },
  computed: {},
  // 监控data中的数据变化
  watch: {},
  onLoad(options) { },
  onShow() { },
  onReady() { },
  mounted() {
    this.getLst();
  },
  methods: {
    async getLst() {
      const res = await getIntegralLogAPI(this.form);
      console.log(res);
      this.total = res.total;
      this.items = res.rows || []
    },

    async scrollBottom() {
      if (this.list.length >= this.total) return;
      if (this.loading) return;
      this.form.pageNum++;
      this.status = "loading";
      this.loading = true;
      const { rows } = await getTalentsListAPI(this.form);
      this.status = "more";
      this.loading = false;
      this.list = [...this.list, ...rows];
    },
  },
};
</script>
<style lang="scss" scoped>
.Water {
  height: 100vh;
  width: 100%;
  background-color: #f9f9f9;

  .scroll {
    width: 100%;
    height: 85vh;

    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 24rpx;

    .date {
      margin: 32rpx 0 0 16rpx;
    }

    .item {
      height: 145rpx;
      padding: 32rpx 24rpx 0;
      background: #ffffff;
      border-radius: 16rpx;
      margin-bottom: 16rpx;

      display: flex;
      justify-content: space-between;
      align-items: center;

      .left {
        .day {
          height: 40rpx;
          font-family: PingFangSC-Medium;
          font-weight: 700;
          font-size: 30rpx;
          color: #000000;
          margin-bottom: 8rpx;
        }

        .time {
          font-weight: 500;
          font-size: 24rpx;
          color: #00000073;
          letter-spacing: 0;
        }
      }

      .right {
        color: #ff9e24;
        font-size: 36rpx;

        font-weight: 700;
        line-height: 0;
        letter-spacing: 0;

        text-align: center;
      }

      .payOut {
        color: #28A3FF;
        font-size: 36rpx;

        font-weight: 700;
        line-height: 0;
        letter-spacing: 0;

        text-align: center;
      }
    }

    .length {
      font-weight: 500;
      font-size: 24rpx;
      color: #00000033;
      letter-spacing: 0;
      text-align: center;
    }
  }
}
</style>
